﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GraphDrawer
{
    public partial class EmptyPopUp : UserControl
    {
        public event RoutedEventHandler Closed;
        public event RoutedEventHandler OK;

        public EmptyPopUp()
        {
            InitializeComponent();            
            this.SetValue(Canvas.ZIndexProperty, 10);
            Closed += new RoutedEventHandler(NewNodePopUp_Closed);
            OK += new RoutedEventHandler(NewNodePopUp_OK);
        }

        void NewNodePopUp_OK(object sender, RoutedEventArgs e)
        {
            Visibility = Visibility.Collapsed;
        }

        void NewNodePopUp_Closed(object sender, RoutedEventArgs e)
        {
            Visibility = Visibility.Collapsed;
        }

        private void CloseBtn_Click(object sender, RoutedEventArgs e)
        {
            Closed.Invoke(sender, e);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OK.Invoke(this, e);
        }        

        public new Visibility Visibility
        {
            get
            {
                return base.Visibility;
            }
            set
            {
                Height = App.Current.Host.Content.ActualHeight;
                Width = App.Current.Host.Content.ActualWidth;
                base.Visibility = value;
            }
        }

        public void AddUserControl(UserControl control)
        {
            btnOk.IsEnabled = false;
            ContentMsg.Children.Clear();
            control.SizeChanged += new SizeChangedEventHandler(control_SizeChanged);
            this.Border.Width = control.Width + 80;
            this.Border.Height = control.Height + 80;
            ContentMsg.Children.Add(control);
            ContentMsg.Height = control.Height;
            ContentMsg.Width = control.Width;
        }

        void control_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            this.Border.Width = e.NewSize.Width + 80;
            this.Border.Height = e.NewSize.Height + 80;
            ContentMsg.Height = e.NewSize.Height;
            ContentMsg.Width = e.NewSize.Width;
        }
    }
}
